<%@page import="RssEasy.Core.CookieHelper"%>
<%@page import="Model.Purchase.PurchaseMaterielOfferList"%>
<%@page import="RssEasy.Core.DateTimeExtend"%>
<%@page import="RssEasy.Core.HttpRequestHelper"%>
<%@page import="Model.Purchase.PurchaseOfferList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    PurchaseOfferList pol = new PurchaseOfferList(pageContext);
    PurchaseMaterielOfferList pmol = new PurchaseMaterielOfferList(pageContext);
    HttpRequestHelper hrh = new HttpRequestHelper(pageContext).request();
    CookieHelper cookie=new CookieHelper(request, response);

    String a = hrh.get("purchaseid");
    String level = cookie.Get("level");
    String myid;
    if (level.equals("0")) {
        myid = cookie.Get("myid");
    } else {
        myid = cookie.Get("level");
    }
    pol.keyvalue("myid", myid).keyvalue("purchaseid", a);
    pol.timestamp();
    pol.append().submit();

    String[] b = hrh.get("counts").split(",");
    for (int i = 0; i < b.length; i++) {
        if (pmol.select("id").where("myid=? and materielid=?",myid, hrh.get("materielid[" + b[i] + "]")).get_first_rows()) {
            out.print("<script>alert('已报价请勿重复报价')</script>");
            out.print("<script>document.location='/purchase/list'</script>");
        }else{
        pmol.keyvalue("myid", myid).keyvalue("purchaseid", a).keyvalue("price", hrh.get("price[" + b[i] + "]")).keyvalue("freight", hrh.get("freight[" + b[i] + "]")).keyvalue("addr", hrh.get("addr[" + b[i] + "]")).keyvalue("spotgoods", hrh.get("spotgoods[" + b[i] + "]")).keyvalue("icourl", hrh.get("icourl[" + b[i] + "]")).keyvalue("materielid", hrh.get("materielid[" + b[i] + "]")).keyvalue("enddt",hrh.get("enddt[" + b[i] + "]"));
        pmol.timestamp();
        pmol.append().submit();
        out.print("<script>alert('报价成功')</script>");
        out.print("<script>document.location='/purchase/list';</script>");
        }
    }
%>
